package com.sky.mapper;

import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.vo.DishVO;
import com.sky.vo.ShoppingParamVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    int save(Dish dish);

    void saveFlavorWithDishId(@Param("flavorList") List<DishFlavor> flavorsList, @Param("dishId") Long dishId);

    List<DishVO> findPage(DishPageQueryDTO pageQueryDTO);

    void updateStatus(Dish build);


    List<Dish> selectSetmealDish(List<Integer> ids);

    List<Dish> selectByIdsAndStatus(List<Integer> ids);

    Integer deleteFlavorByIds(List<Integer> ids);

    Integer deleteDishByIds(List<Integer> ids);

    DishVO findByIdWithFlavors(Long id);

    int updateDish(Dish dish);

    void removeRelatedFlavors(Long id);

    List<DishVO> findDishById(Long id);


    List<DishVO> listDishByCategoryById(Long categoryId);

    @Select("select name,price amount,image from dish where id = #{setmealId}")
    ShoppingParamVO findByIds(Long dishId);
}